/**
  ******************************************************************************
  * @file    main.c
  * @author  MCD Application Team
  * @version V4.0.0
  * @date    21-January-2013
  * @brief   Virtual Com Port Demo main file
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */


/* Includes ------------------------------------------------------------------*/
#include "stm32f3_discovery.h"
#include "usb_config.h"
#include "usb_lib.h"
#include "usb_desc.h"
#include "usb_pwr.h"
#include <stdio.h>


/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Extern variables ----------------------------------------------------------*/
extern __IO uint8_t Receive_Buffer[64];
extern __IO  uint32_t Receive_length ;
extern __IO  uint32_t length ;
uint8_t Send_Buffer[64];
uint32_t packet_sent=1;
uint32_t packet_receive=1;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name  : main.
* Descriptioan    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{
  uint16_t Send_length=0;
  
  Set_System();
  sEE_SPI_LowLevel_Init();
  sEE_CS_HIGH(); 
  Set_USBClock();
  USB_Interrupts_Config();
  USB_Init();
  STM_EVAL_LEDInit(LED4);
  STM_EVAL_LEDOn(LED4);
 
  
  //printf("Received %x",sEE_SendByte(0x33));

  
  while (1) {
    if (bDeviceState == CONFIGURED) {
      CDC_Receive_DATA();
      //Check to see if we have data yet 
      if (Receive_length  != 0) {
        if (packet_sent == 1)
          
        Send_length=sprintf ((char*)Send_Buffer, "Received %x",sEE_SendByte(0x33));
        CDC_Send_DATA ((unsigned char*)Send_Buffer,Send_length);
        Receive_length = 0;
      }
    }
  }
} 

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
